﻿#pragma once

#include <iostream>
#include <thread>

namespace Web
{
	struct Thread
	{
		enum State
		{
			TH_WAIT, TH_WORKING, TH_END
		}  mState = TH_WAIT;

		std::thread* mThread;

        inline State GetState()
        {
            return mState;
        }
		void Start();
		void Detach();
		void Join();
		bool Joinable();
		virtual void Run() = 0;
        ~Thread();

    private:
        static void RunTask(Web::Thread* task);
        void Work();
    };

}
